package com.only4play.common.model;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 分页结果
 *
 * @author liyuncong
 * @date 2023/11/06 14:02
 **/

@Data
public class PageResponse<T> {
    private Integer pageIndex;
    private Integer pageSize;
    private Integer totalPages;
    private Long total;
    private Iterable<T> payload;

    public PageResponse(Iterable<T> payload, Long total, Integer pageSize, Integer pageIndex) {
        this.payload = payload;
        this.total = total;
        this.pageSize = pageSize;
        this.pageIndex = pageIndex;
    }

    public static <T> PageResponse<T> of(Iterable<T> list, Long total, Integer pageSize, Integer pageNumber) {
        return new PageResponse<T>(list, total, pageSize, pageNumber);
    }

}
